<?php

/*
**	Post Short URL
**	Provides ID-based access to blog posts, for shorter URLs.
**
*/

$slug = $this->Ligature_Post_model->getPostSlugFromId($postId);

if ($slug === false) {
    $outcome = 'postNotFound';
} else {
    $outcome = 'postFound';
}

switch ($outcome) {
	/*
		Outcome: Post found
	*/
	case 'postFound':
		$messageClass = 'success';
		redirect('/post/' . $slug);
		break;
	/*
		Outcome: Post not found
	*/
	case 'postNotFound':
		$messageClass = 'failure';
		$this->session->set_flashdata('message', array('class' => $messageClass, 'text' => $this->lang->line('ligature_p_findPost_postNotFound_message')));
		redirect('/');
		break;
	default:
		show_error("Unexpected outcome '$outcome' to action 'findPost' on page 'p'.");
}

/* clickframes::version=4137189691::clickframes */
?>